<?php

/**
 * TestimonyLatestWidget class
 *
 * @author Julot <andy.julot@gmail.com>
 * @since Monday, January 30, 2012. 01:42 PM
 */
class TestimonyLatestWidget extends CWidget {

	public function run() {
		$config = array(
			'criteria'=>array(
				'order'=>'updateTime DESC',
				'limit'=>10
			),
			'pagination'=>false,
		);
		$dataProvider = new CActiveDataProvider('Testimony', $config);
		if ($dataProvider->itemCount) {
			$items = array();
			foreach ($dataProvider->data as $data) {
				$item = array(
					'label'=>$data->name,
					'url'=>array('testimony/view', 'id'=>$data->_id)
				);
				$items[] = $item;
			}
			$data = array('items'=>$items);
			$this->render('testimonyLatest', $data);
		}
	}

}
